import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { ElMessage } from 'element-plus'
import App from './App.vue'
import router from './router'
import './style.css'
import './styles/message.css'
import './styles/global.css'
import MapComponents from './components/map'

// 配置全局的ElMessage默认选项
ElMessage.defaults.duration = 7000 // 设置默认显示时间为7秒
ElMessage.defaults.showClose = true // 默认显示关闭按钮

const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// 使用插件
app.use(createPinia())
app.use(router)
app.use(ElementPlus, {
    locale: zhCn
})

// 注册地图组件
app.use(MapComponents)

// 挂载应用
app.mount('#app')
